package com.jbm.jsm.iface;

import com.jbm.core.iface.IAcross;
import org.hibernate.annotations.*;

import javax.persistence.*;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/9/26.
 */
@Entity
@Table(name = "task", schema = "", catalog = "jsm")
@org.hibernate.annotations.Entity(dynamicUpdate=true,dynamicInsert=true, optimisticLock = OptimisticLockType.VERSION )
public class TaskEntity extends IAcross
{
    @Transient
    public int user_id;
    private int tId;
    private Integer platType; //平台 见枚举
    private Integer taskType;
    private Integer payType;
    private Integer orderNumbers;//任务人数
    private String requirement;//接单要求
    private BigDecimal freight;
    private Integer taskEnvironment; //做单环境
    private BigDecimal fee;
    private String sellerAccount;
    private Timestamp createDate;
    private Integer createId;
    private Integer goodsAmount;
    private String saLevel;
    private Integer sDay;
    private Integer sWeek;
    private Integer sMonth;
    private Integer sIsRealname;
    private Integer sIsSeller;
    private Integer sIsBaduser;
    private Integer isIsMobile;
    private Integer saSex;
    private Integer sSatisfy; //接单人保证金
    private Integer sLimitDay;
    private Integer status;
    private Integer istop;
    private Timestamp topDate;
    private String  comment;//交单条件
    private List<GeoInfoEntity> geolist;
    private List<TaskGoodsEntity> goodsList;
    private List<TaskEntity> taskList;
    private List<OrderEntity> orderlist;
    private UserEntity userEntity;
    private BigDecimal deposit;
    private BigDecimal userpay;
    private Integer mibao;
    private Integer leveldeposit;
    private Integer sucessAmount;//成功单数
    private Integer version;
    private Integer levelValueS; //京享值 低
    private Integer levelValueE; //京享值 高
    private Integer waitReceive; //待收
    private Integer waitComment; //待评价
    private String taskNo;//订单编号
    private Integer tmId;//模板id
    private String platTypeS;//平台 手输入
    private Integer userpayBelong;//垫付归属
    private String doFlow; //接单流程
private List<TaskRequireEntity> requireList; //交单条件
    private Integer doPlatType;
    private BigDecimal perUserpay;//每单垫资款
    private BigDecimal perDeposit;//每单佣金
    private Integer perMibao;//每单米宝
    private BigDecimal perUerpay;
    private BigDecimal mgtCharge;

    public TaskEntity()
    {
        super();
    }

    public TaskEntity(IAcross ia)
    {
        super(ia);
    }

    public TaskEntity (int status,int payType,int platType,int start,int pagesize)
    {
       this.platType=platType;
        this.payType=payType;
        this.status=status;
        this.start=start;
        this.pagesize=pagesize;
    }



    public TaskEntity (int taskEnvironment,int platType,int payType,int taskType,BigDecimal fee,int goodsAmount,int orderNumbers,String saLevel,int sDay,int sWeek,int sMonth,int sIsRealname, int sIsSeller,int sIsBaduser,int saSex,int sSatisfy,int sLimitDay,String   requirement,BigDecimal freight,String comment,List<GeoInfoEntity> geolist,List<TaskGoodsEntity> goodslist)
    {

        this.taskEnvironment=taskEnvironment;
        this.platType=platType;
        this.payType=payType;
        this.taskType=taskType;
        this.fee=fee;
        this.goodsAmount=goodsAmount;
        this.orderNumbers=orderNumbers;
        this.saLevel=saLevel;

        this.sDay=sDay;
        this.sWeek=sWeek;
        this.sMonth=sMonth;



        this.sIsRealname=sIsRealname;
        this.sIsSeller=sIsSeller;
        this.sIsBaduser=sIsBaduser;
        this.saSex=saSex;
        this.sSatisfy=sSatisfy;
        this.sLimitDay=sLimitDay;
        this.requirement=requirement;
        this.freight=freight;
        this.comment=comment;
        this.geolist=geolist;
        this.goodsList=goodslist;

    }

    public void setVersion(int version) {
        this.version = version;
    }

    @Basic
    @Column(name = "sucess_amount")
    public Integer getSucessAmount() {
        return sucessAmount;
    }

    public void setSucessAmount(Integer sucessAmount) {
        this.sucessAmount = sucessAmount;
    }

    @Id
    @Column(name = "t_id")
    @GeneratedValue
    public int gettId() {
        return tId;
    }

    public void settId(int tId) {
        this.tId = tId;
    }

    @Basic
    @Column(name = "plat_type")
    public Integer getPlatType() {
        return platType;
    }

    public void setPlatType(Integer platType) {
        this.platType = platType;
    }

    @Basic
    @Column(name = "task_type")
    public Integer getTaskType() {
        return taskType;
    }

    public void setTaskType(Integer taskType) {
        this.taskType = taskType;
    }

    @Basic
    @Column(name = "pay_type")
    public Integer getPayType() {
        return payType;
    }

    public void setPayType(Integer payType) {
        this.payType = payType;
    }

    @Basic
    @Column(name = "order_numbers")
    public Integer getOrderNumbers() {
        return orderNumbers;
    }

    public void setOrderNumbers(Integer orderNumbers) {
        this.orderNumbers = orderNumbers;
    }

    @Basic
    @Column(name = "requirement")
    public String getRequirement() {
        return requirement;
    }

    public void setRequirement(String requirement) {
        this.requirement = requirement;
    }

    @Basic
    @Column(name = "freight")
    public BigDecimal getFreight() {
        return freight;
    }

    public void setFreight(BigDecimal freight) {
        this.freight = freight;
    }

    @Basic
    @Column(name = "task_environment")
    public Integer getTaskEnvironment() {
        return taskEnvironment;
    }

    public void setTaskEnvironment(Integer taskEnvironment) {
        this.taskEnvironment = taskEnvironment;
    }

    @Basic
    @Column(name = "fee")
    public BigDecimal getFee() {
        return fee;
    }

    public void setFee(BigDecimal fee) {
        this.fee = fee;
    }

    @Basic
    @Column(name = "seller_account")
    public String getSellerAccount() {
        return sellerAccount;
    }

    public void setSellerAccount(String sellerAccount) {
        this.sellerAccount = sellerAccount;
    }

    @Basic
    @Column(name = "create_date")
    public Timestamp getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Timestamp createDate) {
        this.createDate = createDate;
    }

    @Basic
    @Column(name = "create_id")
    public Integer getCreateId() {
        return createId;
    }

    public void setCreateId(Integer createId) {
        this.createId = createId;
    }

    @Basic
    @Column(name = "goods_amount")
    public Integer getGoodsAmount() {
        return goodsAmount;
    }

    public void setGoodsAmount(Integer goodsAmount) {
        this.goodsAmount = goodsAmount;
    }

    @Basic
    @Column(name = "sa_level")
    public String getSaLevel() {
        return saLevel;
    }

    public void setSaLevel(String saLevel) {
        this.saLevel = saLevel;
    }

    @Basic
    @Column(name = "s__day")
    public Integer getsDay() {
        return sDay;
    }

    public void setsDay(Integer sDay) {
        this.sDay = sDay;
    }

    @Basic
    @Column(name = "s_week")
    public Integer getsWeek() {
        return sWeek;
    }

    public void setsWeek(Integer sWeek) {
        this.sWeek = sWeek;
    }

    @Basic
    @Column(name = "s_month")
    public Integer getsMonth() {
        return sMonth;
    }

    public void setsMonth(Integer sMonth) {
        this.sMonth = sMonth;
    }

    @Basic
    @Column(name = "s_is_realname")
    public Integer getsIsRealname() {
        return sIsRealname;
    }

    public void setsIsRealname(Integer sIsRealname) {
        this.sIsRealname = sIsRealname;
    }

    @Basic
    @Column(name = "s_is_seller")
    public Integer getsIsSeller() {
        return sIsSeller;
    }

    public void setsIsSeller(Integer sIsSeller) {
        this.sIsSeller = sIsSeller;
    }

    @Basic
    @Column(name = "s_is_baduser")
    public Integer getsIsBaduser() {
        return sIsBaduser;
    }

    public void setsIsBaduser(Integer sIsBaduser) {
        this.sIsBaduser = sIsBaduser;
    }

    @Basic
    @Column(name = "is_is_mobile")
    public Integer getIsIsMobile() {
        return isIsMobile;
    }

    public void setIsIsMobile(Integer isIsMobile) {
        this.isIsMobile = isIsMobile;
    }

    @Basic
    @Column(name = "sa_sex")
    public Integer getSaSex() {
        return saSex;
    }

    public void setSaSex(Integer saSex) {
        this.saSex = saSex;
    }

    @Basic
    @Column(name = "s_satisfy")
    public Integer getsSatisfy() {
        return sSatisfy;
    }

    public void setsSatisfy(Integer sSatisfy) {
        this.sSatisfy = sSatisfy;
    }

    @Basic
    @Column(name = "s_limit_day")
    public Integer getsLimitDay() {
        return sLimitDay;
    }

    public void setsLimitDay(Integer sLimitDay) {
        this.sLimitDay = sLimitDay;
    }

    @Basic
    @Column(name = "status")
    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    @Basic
    @Column(name = "istop")
    public Integer getIstop() {
        return istop;
    }

    public void setIstop(Integer istop) {
        this.istop = istop;
    }

    @Basic
    @Column(name = "top_date")
    public Timestamp getTopDate() {
        return topDate;
    }

    public void setTopDate(Timestamp topDate) {
        this.topDate = topDate;
    }

    @Basic
    @Column(name = "comment")
    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    @Transient
    public List<GeoInfoEntity> getGeolist() {
        return geolist;
    }

    public void setGeolist(List<GeoInfoEntity> geolist) {
        this.geolist = geolist;
    }

    @Transient
    public List<TaskGoodsEntity> getGoodsList() {
        return goodsList;
    }

    public void setGoodsList(List<TaskGoodsEntity> goodsList) {
        this.goodsList = goodsList;
    }

    @Transient
    public List<TaskEntity> getTaskList() {
        return taskList;
    }

    public void setTaskList(List<TaskEntity> taskList) {
        this.taskList = taskList;
    }

    @Transient
    public List<OrderEntity> getOrderlist() {
        return orderlist;
    }

    public void setOrderlist(List<OrderEntity> orderlist) {
        this.orderlist = orderlist;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        TaskEntity that = (TaskEntity) o;

        if (sWeek != that.sWeek) return false;
        if (tId != that.tId) return false;
        if (createDate != null ? !createDate.equals(that.createDate) : that.createDate != null) return false;
        if (createId != null ? !createId.equals(that.createId) : that.createId != null) return false;
        if (fee != null ? !fee.equals(that.fee) : that.fee != null) return false;
        if (freight != null ? !freight.equals(that.freight) : that.freight != null) return false;
        if (goodsAmount != null ? !goodsAmount.equals(that.goodsAmount) : that.goodsAmount != null) return false;
        if (isIsMobile != null ? !isIsMobile.equals(that.isIsMobile) : that.isIsMobile != null) return false;
        if (istop != null ? !istop.equals(that.istop) : that.istop != null) return false;
        if (orderNumbers != null ? !orderNumbers.equals(that.orderNumbers) : that.orderNumbers != null) return false;
        if (payType != null ? !payType.equals(that.payType) : that.payType != null) return false;
        if (platType != null ? !platType.equals(that.platType) : that.platType != null) return false;
        if (requirement != null ? !requirement.equals(that.requirement) : that.requirement != null) return false;
        if (sDay != null ? !sDay.equals(that.sDay) : that.sDay != null) return false;
        if (sIsBaduser != null ? !sIsBaduser.equals(that.sIsBaduser) : that.sIsBaduser != null) return false;
        if (sIsRealname != null ? !sIsRealname.equals(that.sIsRealname) : that.sIsRealname != null) return false;
        if (sIsSeller != null ? !sIsSeller.equals(that.sIsSeller) : that.sIsSeller != null) return false;
        if (sLimitDay != null ? !sLimitDay.equals(that.sLimitDay) : that.sLimitDay != null) return false;
        if (sMonth != null ? !sMonth.equals(that.sMonth) : that.sMonth != null) return false;
        if (sSatisfy != null ? !sSatisfy.equals(that.sSatisfy) : that.sSatisfy != null) return false;
        if (saLevel != null ? !saLevel.equals(that.saLevel) : that.saLevel != null) return false;
        if (saSex != null ? !saSex.equals(that.saSex) : that.saSex != null) return false;
        if (sellerAccount != null ? !sellerAccount.equals(that.sellerAccount) : that.sellerAccount != null)
            return false;
        if (status != null ? !status.equals(that.status) : that.status != null) return false;
        if (taskEnvironment != null ? !taskEnvironment.equals(that.taskEnvironment) : that.taskEnvironment != null)
            return false;
        if (taskType != null ? !taskType.equals(that.taskType) : that.taskType != null) return false;
        if (topDate != null ? !topDate.equals(that.topDate) : that.topDate != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = tId;
        result = 31 * result + (platType != null ? platType.hashCode() : 0);
        result = 31 * result + (taskType != null ? taskType.hashCode() : 0);
        result = 31 * result + (payType != null ? payType.hashCode() : 0);
        result = 31 * result + (orderNumbers != null ? orderNumbers.hashCode() : 0);
        result = 31 * result + (requirement != null ? requirement.hashCode() : 0);
        result = 31 * result + (freight != null ? freight.hashCode() : 0);
        result = 31 * result + (taskEnvironment != null ? taskEnvironment.hashCode() : 0);
        result = 31 * result + (fee != null ? fee.hashCode() : 0);
        result = 31 * result + (sellerAccount != null ? sellerAccount.hashCode() : 0);
        result = 31 * result + (createDate != null ? createDate.hashCode() : 0);
        result = 31 * result + (createId != null ? createId.hashCode() : 0);
        result = 31 * result + (goodsAmount != null ? goodsAmount.hashCode() : 0);
        result = 31 * result + (saLevel != null ? saLevel.hashCode() : 0);
        result = 31 * result + (sDay != null ? sDay.hashCode() : 0);
        result = 31 * result + sWeek;
        result = 31 * result + (sMonth != null ? sMonth.hashCode() : 0);
        result = 31 * result + (sIsRealname != null ? sIsRealname.hashCode() : 0);
        result = 31 * result + (sIsSeller != null ? sIsSeller.hashCode() : 0);
        result = 31 * result + (sIsBaduser != null ? sIsBaduser.hashCode() : 0);
        result = 31 * result + (isIsMobile != null ? isIsMobile.hashCode() : 0);
        result = 31 * result + (saSex != null ? saSex.hashCode() : 0);
        result = 31 * result + (sSatisfy != null ? sSatisfy.hashCode() : 0);
        result = 31 * result + (sLimitDay != null ? sLimitDay.hashCode() : 0);
        result = 31 * result + (status != null ? status.hashCode() : 0);
        result = 31 * result + (istop != null ? istop.hashCode() : 0);
        result = 31 * result + (topDate != null ? topDate.hashCode() : 0);
        return result;
    }

@Transient
    public UserEntity getUserEntity() {
        return userEntity;
    }

    public void setUserEntity(UserEntity userEntity) {
        this.userEntity = userEntity;
    }

    @Basic
    @Column(name = "deposit", columnDefinition="BigDecimal default 0")
    public BigDecimal getDeposit() {
        return deposit;
    }

    public void setDeposit(BigDecimal deposit) {
        this.deposit = deposit;
    }

    @Basic
    @Column(name = "userpay", columnDefinition="BigDecimal default 0")
    public BigDecimal getUserpay() {
        return userpay;
    }

    public void setUserpay(BigDecimal userpay) {
        this.userpay = userpay;
    }

    @Basic
    @Column(name = "mibao", columnDefinition="int default 0")
    public Integer getMibao() {
        return mibao;
    }

    public void setMibao(Integer mibao) {
        this.mibao = mibao;
    }

    @Basic
    @Column(name = "leveldeposit")
    public Integer getLeveldeposit() {
        return leveldeposit;
    }

    public void setLeveldeposit(Integer leveldeposit) {
        this.leveldeposit = leveldeposit;
    }

    /**
     * 获取模板
     * String tmName,int taskEnvironment,int platType,int payType,int taskType,BigDecimal fee,int goodsAmount,int orderNumbers,String saLevel,int sDay,
     * int sWeek,int sMonth,int sIsRealname, int sIsSeller,int sIsBaduser,
     * int saSex,int sSatisfy,int sLimitDay,String   requirement,BigDecimal freight,String comment,List<GeoInfoEntity> geolist,List<TaskMouldGoodsEntity> goodslist)

     */
    @Transient
    public TaskMouldEntity getModelTemp(String tmName){
        List<TaskMouldGoodsEntity> goods=new ArrayList<TaskMouldGoodsEntity>();
        for (int i = 0; i < getGoodsList().size(); i++) {
            goods.add(getGoodsList().get(i).getGoosList());
        }
        return new TaskMouldEntity(tmName,levelValueS,levelValueE,waitReceive,waitComment,doPlatType,taskEnvironment,platType,payType,taskType,fee,goodsAmount,orderNumbers,saLevel,sDay,sWeek,sMonth,sIsRealname,sIsSeller,sIsBaduser,saSex
                ,sSatisfy,sLimitDay,requirement,freight,comment,geolist,goods);
    }

    @Basic
    @Version
    @Column(name = "version")
    public Integer getVersion() {
        return version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    @Basic
    @Column(name = "wait_receive")
    public Integer getWaitReceive() {
        return waitReceive;
    }

    public void setWaitReceive(Integer waitReceive) {
        this.waitReceive = waitReceive;
    }

    @Basic
    @Column(name = "wait_comment")
    public Integer getWaitComment() {
        return waitComment;
    }

    public void setWaitComment(Integer waitComment) {
        this.waitComment = waitComment;
    }

    @Basic
    @Column(name = "level_value_s")
    public Integer getLevelValueS() {
        return levelValueS;
    }

    public void setLevelValueS(Integer levelValueS) {
        this.levelValueS = levelValueS;
    }

    @Basic
    @Column(name = "level_value_e")
    public Integer getLevelValueE() {
        return levelValueE;
    }

    public void setLevelValueE(Integer levelValueE) {
        this.levelValueE = levelValueE;
    }

    @Basic
    @Column(name = "task_no")
    public String getTaskNo() {
        return taskNo;
    }

    public void setTaskNo(String taskNo) {
        this.taskNo = taskNo;
    }

    @Basic
    @Column(name = "plat_type_s")
    public String getPlatTypeS() {
        return platTypeS;
    }

    public void setPlatTypeS(String platTypeS) {
        this.platTypeS = platTypeS;
    }

    @Basic
    @Column(name = "userpay_belong")
    public Integer getUserpayBelong() {
        return userpayBelong;
    }

    public void setUserpayBelong(Integer userpayBelong) {
        this.userpayBelong = userpayBelong;
    }

    @Basic
    @Column(name = "do_flow")
    public String getDoFlow() {
        return doFlow;
    }

    public void setDoFlow(String doFlow) {
        this.doFlow = doFlow;
    }

    @Basic
    @Column(name = "tm_id")
    public Integer getTmId() {
        return tmId;
    }

    public void setTmId(Integer tmId) {
        this.tmId = tmId;
    }

    @Transient
    public List<TaskRequireEntity> getRequireList() {
        return requireList;
    }

    public void setRequireList(List<TaskRequireEntity> requireList) {
        this.requireList = requireList;
    }

    @Basic
    @Column(name = "do_plat_type")
    public Integer getDoPlatType() {
        return doPlatType;
    }

    public void setDoPlatType(Integer doPlatType) {
        this.doPlatType = doPlatType;
    }



    @Basic
    @Column(name = "per_deposit")
    public BigDecimal getPerDeposit() {
        return perDeposit;
    }

    public void setPerDeposit(BigDecimal perDeposit) {
        this.perDeposit = perDeposit;
    }

    @Basic
    @Column(name = "per_mibao")
    public Integer getPerMibao() {
        return perMibao;
    }

    public void setPerMibao(Integer perMibao) {
        this.perMibao = perMibao;
    }

    @Basic
    @Column(name = "per_uerpay")
    public BigDecimal getPerUserpay() {
        return perUserpay;
    }

    public void setPerUserpay(BigDecimal perUserpay) {
        this.perUserpay = perUserpay;
    }


    @Basic
    @Column(name = "mgt_charge")
    public BigDecimal getMgtCharge() {
        return mgtCharge;
    }

    public void setMgtCharge(BigDecimal mgtCharge) {
        this.mgtCharge = mgtCharge;
    }
}
